<template>
	<view class="bg-F5F5F5" style="padding-bottom: 20rpx;">
		<view class=""
			style="height: 256rpx;background: linear-gradient(127deg, #9CECFB 0%, #65C7F7 26%, #0052D4 100%);overflow: hidden;border-radius: 0px 0px 55rpx 55rpx;">
			<view class="flex bg-FFFFFF"
				style="border-radius: 10rpx;  margin-left: 100rpx;margin-right: 100rpx;margin-top: 60rpx; height: 90rpx;">
				<view class="bg-FFFFFF aj-center" style="width: 410rpx;border-radius: 10rpx 0rpx 0rpx 10rpx;">
					<input class="c-11" type="text" v-model="phonenum" value="" placeholder="输入手机号查询" />
				</view>
				<view class="aj-center" style="background-color: #D2E7FF;width: 140rpx;border-radius: 10rpx "
					@click="search">
					查询
				</view>
			</view>
		</view>
		<view class="mx-30">
			<view class="" style="margin-top: 36rpx;  margin-bottom: 36rpx; font-size: 28rpx;  font-weight: bold; "
				v-if="lastchange">
				近期核销明细
			</view>
			<view class="" v-if="lastchange"> 
				<x-indent-details 
				v-for="(item,index) in finished_list" :key="index" 
				:createtime="item.createtime" :data="item" :order_info="item.goods_info" />
			</view>
			<view class="" v-if="!lastchange">
				<!-- <view class="mt-20" v-if="change"> -->
				<!-- <view class="mt-20" v-if="data.status==3"> -->
				<!-- 有待核销的 -->
				<view class="mt-20" v-if="wait_list.length>0 && state!=1 ">

					<x-indent-change changes="验证成功">
						<image src="../static/doct/changeindent.png" slot="img" mode=""></image>
					</x-indent-change>
				</view>

				<!-- <view class="mt-20" v-if="allchange"> -->
				<!-- <view class="mt-20" v-if="msg=='请输入核销手机号！'"> -->
				<view class="mt-20" v-if="state==1">
					<x-indent-change changes="验证失败">
						<image src="../static/doct/cha.png" slot="img" mode=""></image>
					</x-indent-change>
				</view>
				<!-- <view class="mt-20" v-if="fuckchange"> -->
				<!-- <view class="mt-20" v-if="data.status==4"> -->
				<!-- 待核销的数组为空就是没有核销的数据了   这里显示已核销的数据 -->
				<view class="mt-20" v-if="wait_list.length==0 && state!=1">
					<x-indent-change changes="订单已被核销">
						<image src="../static/doct/jg.png" slot="img" mode=""></image>
					</x-indent-change>
				</view>
				<!-- 内容区域 -->
				<!-- <view class="" style="margin-top: 23rpx;" v-if="!allchange"> -->
				<view class="" style="margin-top: 23rpx;" v-if="state!=1">
					<block v-if="wait_list.length==0 && state!=1">
						<!-- 显示已核销的数据 -->
						<x-indent-details
						v-for="(item,index) in finished_list" :key="index" 
						 :createtime="item.createtime" :data="item" :order_info="item.goods_info" />
					</block>
					<block v-if="wait_list.length!=0 && state!=1">
						<!-- 显示待核销的数据 -->
						<x-indent-details v-for="(item,index) in wait_list" :key="index"  :createtime="item.createtime"
						 :data="item" :order_info="item.goods_info" />
					</block>
				</view> 
				<!-- <view class="mt-10 aj-center f-bold f-34 bg-FFFFFF bor-r10" v-if="allchange"
					style=" height: 148rpx;color: #101010;"> -->
				<view class="mt-10 aj-center f-bold f-34 bg-FFFFFF bor-r10" v-if="state==1"
					style=" height: 148rpx;color: #101010;">
					验证号码不存在，请确认后重试。
				</view>

				<!-- 核销按钮 -->
				<!-- <view class="mt-10" v-if="change "> -->
				<!-- <view class="mt-10" v-if="wait_list.length>0 && (state!=1)">
					<x-Indent-button :order_id="wait_list.order_id" />
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	// props:['data',"order_info"],
	export default {
		data() {
			return {
				state: '', //核销失败状态码
				data: null, //查询的全部数据
				time:'',
				// order_info: null, //查询的商品的数据
				msg: '', //手机号查不到没返回状态  先使用返回的文字代替
				phonenum: '', //手机号
				lastchange: true, //不输入手机号查询
				change: false,
				allchange: false, //打辅助的验证失败
				fuckchange: false, //订单被核销
				wait_list: [], //待核销订单
				finished_list: [], //已核销订单

			}
		},
		onShow() {
			this.queryWriteOff()
		},
		methods: {
			search() {
				this.change = false;
				this.allchange = false;
				this.fuckchange = false;
				if (this.phonenum.length == 11) {
					this.queryWriteOff();
					this.lastchange = false;
				} else {
					console.log('手机号11位')
				}

				// if (this.phonenum == 1) {
				// 	this.change = true;
				// 	this.phonenum = ''
				// 	return;
				// }
				// if (this.phonenum == 2) {
				// 	this.allchange = true
				// 	this.phonenum = ''
				// 	return;
				// }
				// if (this.phonenum == 3) {
				// 	this.fuckchange = true
				// 	this.phonenum = ''
				// 	return;
				// }
				// this.lastchange = true;
				console.log('1111')
			},
			queryWriteOff() {
				this.$https("doctindex.queryWriteOff", {
					mobile: this.phonenum
				}).then(res => {
					console.log(res, '手机号搜索')
					this.state = res.data.state; //核销失败状态码 
					this.data = res.data; //所有的状态
					// this.msg=res.msg;
					// this.order_info = res.data.goods_info;
					//待核销订单
					this.wait_list = res.data.wait_list;
					//已核销订单
					this.finished_list = res.data.finished_list;
					this.time=res.time;
				})
			}
		}
	}
</script>

<style scoped>
	@import url("@/common/css/fress.css");
	@import url("@/common/css/mycss.css");
</style>
